package com.biz.primus.ms.order.convertor;

import com.biz.primus.base.enums.PromotionTypeEnum;
import com.biz.primus.base.exception.BizSilentException;
import com.biz.primus.model.order.exception.OrderException;
import com.biz.primus.model.order.vo.OrderVO;
import com.biz.primus.model.order.vo.OrderPromotionVO;
import com.biz.primus.model.order.vo.request.OrderRequestVO;
import com.biz.primus.model.order.vo.response.OrderPromotionResponseVO;
import com.biz.primus.model.order.vo.response.OrderResponseVO;
import com.biz.primus.model.promotion.vo.OrderPromotionDetailVo;
import com.biz.primus.ms.order.dao.po.embeddable.OrderPromotion;

/**
 * 订单促销转换器
 *
 * @author Tiger Feng
 * @date 2017年11月09日
 */
public class OrderPromotionConvertor {
    /**
     * OrderPromotionDetailVo 转 OrderPromotionRequestVO
     *
     * @param detailVo
     * @return
     */
    public static OrderPromotionVO detailVO2RequestVO(OrderPromotionDetailVo detailVo, OrderRequestVO orderVO) {
        if(detailVo == null || orderVO == null){
            throw new BizSilentException(OrderException.COVERTOR_EXCEPTION);
        }
        return new OrderPromotionVO(orderVO.getOrderType(),orderVO.getOrderCode(),detailVo.getId());
    }

    public static OrderPromotion detailVO2PO(OrderPromotionResponseVO vo){
        if(vo == null){
            throw new BizSilentException(OrderException.COVERTOR_EXCEPTION);
        }
        OrderPromotion po = new OrderPromotion();
        po.setPromotionId(vo.getId());
        po.setPromotionType(vo.getPromotionType());
        po.setPromotionAllowCoupon(vo.getAllowCoupon());
        po.setPromotionDescription(vo.getDescription());
        po.setPromotionName(vo.getName());
        return  po;
    }
}
